package vip.liux.backend.adapter.task.pay.notify;


import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import vip.liux.backend.application.service.pay.PayNotifyService;
import vip.liux.backend.application.service.pay.PayOrderService;


/**
 * 支付通知 Job
 * 通过不断扫描待通知的 PayNotifyTaskDO 记录，回调业务线的回调接口
 *
 * @author 芋道源码
 */
@Component
@Slf4j
public class PayNotifyJob {

    @Resource
    private PayNotifyService payNotifyService;

    @Resource
    private PayOrderService orderService;

    @Scheduled(fixedDelay = 500000) // 每 5 秒执行一次
    public void executeNotify() throws InterruptedException {
        payNotifyService.executeNotify();
    }

    public void expireOrder() {
        orderService.expireOrder();
    }
}
